<?php
/**
 * Date: 2024.8
 * Author: kahn
 */
namespace models\vip;

use config\Order as OrderConfig;
use driver\ThinkOrm;
use think\Model;

class OrderModel extends ThinkOrm
{
    protected $table = 'vip_order';
    protected $pk = 'id';

    /**
     * @param $userId
     * @return int
     */
    public static function countByUserId($userId): int
    {
        return static::where('userId',$userId)
            ->where('deleted',OrderConfig::ORDER_DELETED_NO)
            ->count();

    }

    public static function list($userId): array
    {
        return static::where('userId',$userId)
            ->where('deleted',OrderConfig::ORDER_DELETED_NO)
            ->field('id,sn,status,price,discount,title,payment,createdTime,paidTime')
            ->select()
            ->toArray();
    }



}
